<?php

namespace app\index\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'  =>  'require|alphaDash',
        'password' =>  'require',
        // 注册时验证的密码
        'usernameReg'  =>  'require|min:6|max:11|alphaDash',
        'passwordReg' =>  'require|min:8|max:16|alphaDash',
        'newPassword' =>  'require|min:8|max:16|alphaDash',
        'email' => 'require|email'
        ,'role' => 'require|number'
        ,'status' => 'number'
        ,'score' => 'number'
    ];
    protected $message = [
        'username.require' => '用户名不能为空'
        ,'password.require' => '密码不能为空'
        ,'email.require' => '邮箱不能为空'
        ,'nickname.require' => '昵称不能为空'
        ,'usernameReg.require' => '用户名不能为空'
        ,'passwordReg.require' => '密码不能为空'
        ,'passwordReg.min' => '密码长度至少为8'
        ,'passwordReg.max' => '密码长度最大为16'
        ,'passwordReg.alphaDash' => '密码只能由字母和数字，下划线_及破折号-组成'

        ,'newPassword.require' => '新密码不能为空'
        ,'newPassword.min' => '新密码长度至少为8'
        ,'newPassword.max' => '新密码长度最大为16'
        ,'passwordReg.alphaDash' => '新密码只能由字母和数字，下划线_及破折号-组成'

        ,'newPassword.require' => '密码不能为空'
        ,'usernameReg.min' => '用户名长度至少为6'
        ,'usernameReg.max' => '用户名长度最大为11'
       
    ];
    protected $scene  = [
        'login' => ['username' , 'password']
        ,'register' => ['usernameReg' , 'passwordReg' , 'email' , 'nickname']
        // 更新个人信息
        ,'update' => ['email' , 'nickname']
        // 更换密码
        ,'changePwd' => ['password' , 'newPassword']
    ];
    
}